# 卸载mariadb
    rpm -qa | grep mariadb
    rpm -e 版本号 --nodeps

# 解压tar 
# 安装commom 
rpm -ivh mysql-community-common-8.0.25-1.el8.x86_64.rpm --nodeps --force
    # mysql-community-common-8.0.25-1.el8.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
# 安装libs
rpm -ivh mysql-community-libs-8.0.25-1.el8.x86_64.rpm --nodeps --force
#  
rpm -ivh --nodeps --force mysql-community-client-8.0.11-1.el7.x86_64.rpm  
rpm -ivh --nodeps --force mysql-community-server-8.0.11-1.el7.x86_64.rpm  

# 查看
rpm -qa | grep mysql

# 初始化
mysqld --initialize;
chown mysql:mysql /var/lib/mysql -R;
systemctl start mysqld.service;
systemctl enable mysqld;

# 查看密码
cat /var/log/mysqld.log | grep password 
    # root@localhost: n*paSDM+p4Tj
    
# 登录数据库
mysql -uroot -p
# 修改密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '12345678';

# 修改root用户远程访问权限：
    # 选择 mysql 数据库
    use mysql;
    # 在 mysql 数据库的 user 表中查看当前 root 用户的相关信息：
    select host, user from user;
    # 授权 root 用户的所有权限并设置远程访问
    GRANT ALL ON *.* TO 'root'@'%';
        # ERROR 1410 (42000): You are not allowed to create a user with GRANT
        update user set host='%' where user ='root';
        # 是命令生效
        flush privileges;
        GRANT ALL ON *.* TO 'root'@'%';
    flush privileges;

sqlyog链接时出现2058异常

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

其中password为自己修改的密码。然后SQLyog中重新连接，则可连接成功，OK。

如果报错：ERROR 1396 (HY000): Operation ALTER USER failed for ‘root’@'localhost’则使用下面命令：

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
